def log_request(req:'flask_request',res:str)->None:
	with open('vsearch.log','a') as log:
		print(req.form,req.remote_addr,req.user_agent,res,file=log,sep='|')


@app.route('/00')
def entry_page() ->'html':
	return render_template('yemian1.html',the_title='HELLO！')



@app.route('/ob',methods=['POST'])
def go_search():
	address = request.form['address']
	codes = str(geocode(address)['geocodes'][0][ 'location'])

	location = codes
	types = request.form['types']
	results = POI(location,types)['pois']

	names = []
	address2 = []
	for i in results:
		names.append(i['name'])
		address2.append(i['address'])
	combine = dict(zip(names,address2))
	log_request(request,results)
	return render_template('yemian2.html',res=combine,the_title='搜索结果',)



@app.route('/viewlog')
def view_the_log() ->'html':
	contents = []
	with open('vsearch.log') as log:
		for line in log:
			contents.append([])
			for item in line.split('|'):
				contents[-1].append(escape(item))
	titles = ('Form Data','Remote_addr','User_agent','Results')
	return render_template('viewlog.html',
		the_title='View Log',
		the_row_titles=titles,
		the_data=contents,)

app.run(debug=True)